# -*- coding:utf-8 -*-

from server.action.batchBase import batchBase
from server.util import sqlBuild, stringUtil
import uuid


class lcdc(batchBase):  # 关盖
    @batchBase.idChecked
    def action(self, data, d):
        baId, lcId = data[0], data[2]
        lb = stringUtil.redis_key_name(baId)

        self.re.lset(lb, 1, 0)  # 更新为正常状态
        sql = sqlBuild.sqlDict["update_lampClient_state"] % (0, lcId)
        self.db.update(sql)

        data = "提示：路灯[%s]，已关盖，请及时处理！" % lcId
        self.re.publish('faultMessage', data)  # send state to the fan service, use redis's pubsub() method

        d.callback((2,))
